<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>键盘事件</title>
</head>
<body>

</body>
</html>
<script>
    //keydown 键盘按下
    //keyup 键盘松开
    //keypress 键盘按下再松开

    window.addEventListener('keypress',function(e){
        //IE不支持
        console.log(e.code);
        //支持大小写
        console.log(e.charCode);
        //不支持大小写
        console.log(e.keyCode);
        //console.log('你按下了某个键');
        //shiftKey,altKey,ctrlKey,metaKey分别可以进行判断是否按下了某些键
        if(e.code == '65' && e.shiftKey){
            console.log('您按下了a + shift键');
        }
    })
</script>